//
//  SmallImage.m
//  StarFortune
//
//  Created by student on 14-10-13.
//  Copyright (c) 2014年 niit. All rights reserved.
//

#import "SmallImage.h"
#define labelFont [UIFont systemFontOfSize:10]

@implementation SmallImage

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *imageview = [[UIImageView alloc]init];
        imageview.userInteractionEnabled = YES;
       
        [self addSubview:imageview];
        _imageView = imageview;
        
        UILabel *iconlabel = [[UILabel alloc]init];
        iconlabel.textAlignment = NSTextAlignmentCenter;
        iconlabel.font = labelFont;
        [self addSubview:iconlabel];
        _iconName = iconlabel;
        
        UILabel *monthlabel = [[UILabel alloc]init];
        monthlabel.font = labelFont;
        monthlabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:monthlabel];
        _month = monthlabel;
        
    }
    return self;
}

//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
//{
//    NSLog(@"xxxx");
//}

- (void)setModel:(NetRequestModel *)model
{
    _model = model;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat imageX = 0;
    CGFloat imageY = 0;
    _imageView.frame = CGRectMake(imageX, imageY, imageWH, imageWH);
    
    CGFloat iconLableX = 0;
    CGFloat iconLableY = CGRectGetMaxY(_imageView.frame);
    CGFloat iconLableW = self.frame.size.width;
    CGFloat iconLalbeH = labelH;
    _iconName.frame = CGRectMake(iconLableX, iconLableY, iconLableW, iconLalbeH);
    
    CGFloat monthLableX = 0;
    CGFloat monthLableY = CGRectGetMaxY(_iconName.frame);
    CGFloat monthLableW = self.frame.size.width;
    CGFloat monthLalbeH = labelH;
    _month.frame = CGRectMake(monthLableX, monthLableY, monthLableW, monthLalbeH);
}

@end
